class Solution {
    public String modifyString(String s) {
        char[] arr = s.toCharArray() ;
        int len = arr.length ;
        for(int i=0 ; i< len ; i ++){
            if(arr[i] == '?'){
                if(i == 0){
                 if(i+1 < len){
                    if(arr[i+1] =='?'){
                      arr[i] = 'a' ;       
                    }else{
                      arr[i] =  arr[i+1]<'z'?( (char) (arr[i+1]+1)) : ((char)(arr[i+1]-1));  
                    }
                 }else{
                   arr[i] = 'a' ; 
                 }
                }else if(i==len-1){
                    arr[i] = arr[i-1]<'z' ? ((char)(arr[i-1]+1)) : ((char)(arr[i-1]-1));
                }else{
                   if(arr[i+1] == '?'){
                     arr[i] = arr[i-1]<'z' ? ((char)(arr[i-1]+1)): ((char)(arr[i-1]-1));
                   }else{
                      for(int j=0 ; j<=26 ; j ++){
                        char ch = (char)('a'+j) ; 
                        if(ch != arr[i-1] && ch != arr[i+1]){
                            arr[i] = ch ;
                            break ;
                        }
                      }
                   }
                }
            }
        }
        return new String(arr) ; 
    }
}